package com.cheng.example.book.advise151.chap3;


class Employee extends Person_47 {
    private int id;

    public Employee(String _name, int _id) {
        super(_name);
        id = _id;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Employee) {
            Employee e = (Employee) obj;
            return super.equals(obj) && e.getId() == id;
        }
        return false;
    }

}

class Person_47 {
    private String name;

    public Person_47(String _name) {
        name = _name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Person) {
            Person p = (Person) obj;
            if (null == p.getName() || null == name) {
                return false;
            } else {
                return name.equalsIgnoreCase(p.getName());
            }
        }
        return false;
    }
}


public class Client47 {

    public static void main(String[] args) {
        Employee e1 = new Employee("张三", 100);
        Employee e2 = new Employee("张三", 1000);
        Person p1 = new Person("张三");
        System.out.println(p1.equals(e1));
        System.out.println(p1.equals(e2));
        System.out.println(e1.equals(e2));

    }
}
